package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysStudy;
import com.ruoyi.system.service.ISysStudyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教育改造Controller
 * 
 * @author fengzy
 * @date 2022-04-10
 */
@RestController
@RequestMapping("/system/study")
public class SysStudyController extends BaseController
{
    @Autowired
    private ISysStudyService sysStudyService;

    /**
     * 查询教育改造列表
     */
    @PreAuthorize("@ss.hasPermi('system:study:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysStudy sysStudy)
    {
        startPage();
        List<SysStudy> list = sysStudyService.selectSysStudyList(sysStudy);
        return getDataTable(list);
    }

    /**
     * 导出教育改造列表
     */
    @PreAuthorize("@ss.hasPermi('system:study:export')")
    @Log(title = "教育改造", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysStudy sysStudy)
    {
        List<SysStudy> list = sysStudyService.selectSysStudyList(sysStudy);
        ExcelUtil<SysStudy> util = new ExcelUtil<SysStudy>(SysStudy.class);
        return util.exportExcel(list, "study");
    }

    /**
     * 获取教育改造详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:study:query')")
    @GetMapping(value = "/{studyId}")
    public AjaxResult getInfo(@PathVariable("studyId") Long studyId)
    {
        return AjaxResult.success(sysStudyService.selectSysStudyById(studyId));
    }

    /**
     * 新增教育改造
     */
    @PreAuthorize("@ss.hasPermi('system:study:add')")
    @Log(title = "教育改造", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysStudy sysStudy)
    {
        return toAjax(sysStudyService.insertSysStudy(sysStudy));
    }

    /**
     * 修改教育改造
     */
    @PreAuthorize("@ss.hasPermi('system:study:edit')")
    @Log(title = "教育改造", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysStudy sysStudy)
    {
        return toAjax(sysStudyService.updateSysStudy(sysStudy));
    }

    /**
     * 删除教育改造
     */
    @PreAuthorize("@ss.hasPermi('system:study:remove')")
    @Log(title = "教育改造", businessType = BusinessType.DELETE)
	@DeleteMapping("/{studyIds}")
    public AjaxResult remove(@PathVariable Long[] studyIds)
    {
        return toAjax(sysStudyService.deleteSysStudyByIds(studyIds));
    }
}
